#include "stdafx.h"
#include "FCChartEx.h"
#include "FCDraw.h"
#include "MyChart.h"

FCChartEx::FCChartEx(){
    m_myChart = 0;
    m_subComboBox = 0;
}

FCChartEx::~FCChartEx(){
    m_myChart = 0;
    m_subComboBox = 0;
}

void FCChartEx::onAdd(){
    FCChart::onAdd();
    if (!m_subComboBox)
    {
        m_subComboBox = new FCComboBox();
        addView(m_subComboBox);
        m_subComboBox->setVisible(false);
        m_subComboBox->setReadOnly(true);
        m_subComboBox->setLineHeight(10);
        m_subComboBox->setBorderColor(FCColor_None);
        m_subComboBox->setText(L"不复权");
        m_subComboBox->setTextColor(FCColor_Text);
        ArrayList<String> subStrs;
        subStrs.add(L"前复权");
        subStrs.add(L"后复权");
        subStrs.add(L"不复权");
        for (int i = 0; i < subStrs.size(); i++)
        {
            FCMenuItem *menuItem = new FCMenuItem();
            menuItem->setText(subStrs.get(i));
            menuItem->setBorderColor(FCColor_None);
            m_subComboBox->addItem(menuItem);
        }
        m_subComboBox->update();
        m_subComboBox->setSelectedIndex(0);
        m_subComboBox->getDropDownButton()->setBorderColor(FCColor_None);
        m_subComboBox->getDropDownMenu()->setMinimumSize({80, 60});
    }
}

int FCChartEx::getSubScription(){
    int sIndex = m_subComboBox->getSelectedIndex();
    if (sIndex == 0)
    {
        return 1;
    }
    else if (sIndex == 1)
    {
        return 2;
    }
    else
    {
        return 0;
    }
}

void FCChartEx::drawChartCrossLine(FCPaint* paint, const FCRect& clipRect) {
    if (m_datas.size() == 0)
    {
        return;
    }
    FCSize size = getSize();
    int candleDivHeight = getCandleDivHeight();
    int volDivHeight = getVolDivHeight();
    int indDivHeight = getIndDivHeight();
    int indDivHeight2 = getIndDivHeight2();
    int crossLineIndex = m_crossStopIndex;
    if (crossLineIndex == -1 || !m_showCrossLine)
    {
        if (m_lastValidIndex != -1)
            {
                crossLineIndex = m_lastValidIndex;
            }
            else
            {
                crossLineIndex = m_lastVisibleIndex;
            }
    }
if(crossLineIndex == -1)
{
return;
}
    if (volDivHeight > 0)
    {
        ArrayList<String> drawTitles;
        ArrayList<Long> drawColors;
        drawTitles.add((String)L"VOL " +
            FCTran::getValueByDigit(m_datas.get(crossLineIndex).m_volume / m_magnitude, m_volDigit));
        drawColors.add(getTextColor());
        if (m_shapes.size() > 0)
        {
            for (int i = 0; i < m_shapes.size(); i++)
            {
                BaseShape *shape = m_shapes.get(i);
                if (shape->m_divIndex == 1)
                {
                    if ((int)shape->m_title.length() > 0)
                    {
                        if (shape->m_shapeType == L"bar" && shape->m_style == L"2color")
                        {
                            drawTitles.add(shape->m_title +
                                L" " +
                                FCTran::getValueByDigit(shape->m_datas.get(crossLineIndex), m_volDigit));
                            drawColors.add(shape->m_color2);
                        }
                        else
                        {
                            if (shape->m_shapeType != L"text")
                            {
                                drawTitles.add(shape->m_title +
                                    L" " +
                                    FCTran::getValueByDigit(shape->m_datas.get(crossLineIndex), m_volDigit));
                                drawColors.add(shape->m_color);
                                if (shape->m_datas2.size() > 0)
                                {
                                    drawTitles.add(shape->m_title2 +
                                       L" " +
                                        FCTran::getValueByDigit(shape->m_datas2.get(crossLineIndex), m_volDigit));
                                    drawColors.add(shape->m_color2);
                                }
                            }
                        }
                    }
                }
            }
        }
        int iLeft = m_leftVScaleWidth + 5;
        for (int i = 0; i < drawTitles.size(); i++)
        {
            FCSize tSize = paint->textSize(drawTitles.get(i), getFont());
            FCRect dRect = { iLeft, candleDivHeight + 5, iLeft + tSize.cx, candleDivHeight + 5 + tSize.cy };
            paint->drawText(
                drawTitles.get(i), drawColors.get(i), getFont(), dRect);
            iLeft += tSize.cx + 5;
        }
    }
    //上面显示数据  高开低收
    if (m_cycle == L"trend")
    {
        ArrayList<String> drawTitles;
        ArrayList<Long> drawColors;
if((int)m_text.length() > 0){
            drawTitles.add(m_text);
            drawColors.add(getTextColor());
        }
        if (m_shapes.size() > 0)
        {
            for (int i = 0; i < m_shapes.size(); i++)
            {
                BaseShape *shape = m_shapes.get(i);
                if (shape->m_divIndex == 0)
                {
                    if ((int)shape->m_title.length() > 0)
                    {
                        if (shape->m_shapeType == L"bar" && shape->m_style == L"2color")
                        {
                            drawTitles.add(shape->m_title +
                                L" " +
                                FCTran::getValueByDigit(shape->m_datas.get(crossLineIndex), m_candleDigit));
                            drawColors.add(shape->m_color2);
                        }
                        else
                        {
                            if (shape->m_shapeType != L"text")
                            {
                                drawTitles.add(shape->m_title +
                                    L" " +
                                    FCTran::getValueByDigit(shape->m_datas.get(crossLineIndex), m_candleDigit));
                                drawColors.add(shape->m_color);
                                if (shape->m_datas2.size() > 0)
                                {
                                    drawTitles.add(shape->m_title2 +
                                        L" " +
                                        FCTran::getValueByDigit(shape->m_datas2.get(crossLineIndex), m_candleDigit));
                                    drawColors.add(shape->m_color2);
                                }
                            }
                        }
                    }
                }
            }
        }
        int iLeft = m_leftVScaleWidth + 5;
        for (int i = 0; i < drawTitles.size(); i++)
        {
            FCSize tSize = paint->textSize(drawTitles.get(i), getFont());
            FCRect dRect = { iLeft, 5, iLeft + tSize.cx, 5 + tSize.cy };
            paint->drawText(drawTitles.get(i), drawColors.get(i), getFont(), dRect);
            iLeft += tSize.cx + 5;
        }
    }
    else
    {
        ArrayList<String> drawTitles;
        ArrayList<Long> drawColors;
if((int)m_text.length() > 0){
            drawTitles.add(m_text);
            drawColors.add(getTextColor());
        }
        if (m_mainIndicator == L"MA")
        {
            if (m_ma5.size() > 0)
            {
                drawTitles.add((String)L"MA5 " +
                    FCTran::getValueByDigit(m_ma5.get(crossLineIndex), m_candleDigit));
            }
            else
            {
                drawTitles.add(L"MA5");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_ma10.size() > 0)
            {
                drawTitles.add((String)L"MA10 " +
                    FCTran::getValueByDigit(m_ma10.get(crossLineIndex), m_candleDigit));
            }
            else
            {
                drawTitles.add(L"MA10");
            }
            drawColors.add(m_indicatorColors.get(1));
            if (m_ma20.size() > 0)
            {
                drawTitles.add((String)L"MA20 " +
                    FCTran::getValueByDigit(m_ma20.get(crossLineIndex), m_candleDigit));
            }
            else
            {
                drawTitles.add(L"MA20");
            }
            drawColors.add(m_indicatorColors.get(2));
            if (m_ma30.size() > 0)
            {
                drawTitles.add((String)L"MA30 " +
                    FCTran::getValueByDigit(m_ma30.get(crossLineIndex), m_candleDigit));
            }
            else
            {
                drawTitles.add(L"MA30");
            }
            drawColors.add(m_indicatorColors.get(5));
            if (m_ma120.size() > 0)
            {
                drawTitles.add((String)L"MA120 " +
                    FCTran::getValueByDigit(m_ma120.get(crossLineIndex), m_candleDigit));
            }
            else
            {
                drawTitles.add(L"MA120");
            }
            drawColors.add(m_indicatorColors.get(4));
            if (m_ma250.size() > 0)
            {
                drawTitles.add((String)L"MA250 " +
                    FCTran::getValueByDigit(m_ma250.get(crossLineIndex), m_candleDigit));
            }
            else
            {
                drawTitles.add(L"MA250");
            }
            drawColors.add(m_indicatorColors.get(3));
        }
        else if (m_mainIndicator == L"BOLL")
        {
            if (m_bollMid.size() > 0)
            {
                drawTitles.add((String)L"MID " +
                    FCTran::getValueByDigit(m_bollMid.get(crossLineIndex), m_candleDigit));
            }
            else
            {
                drawTitles.add(L"MID");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_bollUp.size() > 0)
            {
                drawTitles.add((String)L"UP " +
                    FCTran::getValueByDigit(m_bollUp.get(crossLineIndex), m_candleDigit));
            }
            else
            {
                drawTitles.add(L"UP");
            }
            drawColors.add(m_indicatorColors.get(1));
            if (m_bollDown.size() > 0)
            {
                drawTitles.add((String)L"LOW " +
                    FCTran::getValueByDigit(m_bollDown.get(crossLineIndex), m_candleDigit));
            }
            else
            {
                drawTitles.add(L"LOW");
            }
            drawColors.add(m_indicatorColors.get(2));
        }
        if (m_shapes.size() > 0)
        {
            for (int i = 0; i < m_shapes.size(); i++)
            {
                BaseShape *shape = m_shapes.get(i);
                if (shape->m_divIndex == 0)
                {
                    if (shape->m_title.length() > 0)
                    {
                        if (shape->m_shapeType == L"bar" && shape->m_style == L"2color")
                        {
                            drawTitles.add(shape->m_title +
                                L" " +
                                FCTran::getValueByDigit(shape->m_datas.get(crossLineIndex), m_candleDigit));
                            drawColors.add(shape->m_color2);
                        }
                        else
                        {
                            if (shape->m_shapeType != L"text")
                            {
                                drawTitles.add(shape->m_title +
                                    L" " +
                                    FCTran::getValueByDigit(shape->m_datas.get(crossLineIndex)
                                        , m_candleDigit));
                                drawColors.add(shape->m_color);
                                if (shape->m_datas2.size() > 0)
                                {
                                    drawTitles.add(shape->m_title2 +
                                        L" " +
                                        FCTran::getValueByDigit(shape->m_datas2.get(crossLineIndex)
                                            , m_candleDigit));
                                    drawColors.add(shape->m_color2);
                                }
                            }
                        }
                    }
                }
            }
        }
        int iLeft = m_leftVScaleWidth + 5;
        for (int i = 0; i < drawTitles.size(); i++)
        {
            FCSize tSize = paint->textSize(drawTitles.get(i), getFont());
            FCRect dRect = { iLeft, 5, iLeft + tSize.cx, 5 + tSize.cy };
            paint->drawText(drawTitles.get(i), drawColors.get(i), getFont(), dRect);
            if (i == 0 && m_text.length() > 0)
            {
                int midY = 12;
                FCSize cSize = paint->textSize(m_subComboBox->getText(), m_subComboBox->getFont(), -1);
                int sWidth = cSize.cx + 25;
                FCRect subBounds = {iLeft + tSize.cx + 8, midY - 10, iLeft + tSize.cx + 8 + sWidth, midY + 10};
                m_subComboBox->setBounds(subBounds);
                iLeft += sWidth + 16;
            }
            iLeft += tSize.cx + 5;
        }
    }
    if (indDivHeight > 0)
    {
        ArrayList<String> drawTitles;
        ArrayList<Long> drawColors;
        if (m_showIndicator == L"MACD")
        {
            if (m_alldifarr.size() > 0)
            {
                drawTitles.add((String)L"DIF " +
                    FCTran::getValueByDigit(m_alldifarr.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"DIF");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_alldeaarr.size() > 0)
            {
                drawTitles.add((String)L"DEA " +
                    FCTran::getValueByDigit(m_alldeaarr.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"DEA");
            }
            drawColors.add(m_indicatorColors.get(1));
            if (m_allmacdarr.size() > 0)
            {
                drawTitles.add((String)L"MACD " +
                    FCTran::getValueByDigit(m_allmacdarr.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"MACD");
            }
            drawColors.add(m_indicatorColors.get(4));
        }
        else if (m_showIndicator == L"KDJ")
        {
            if (m_kdjK.size() > 0)
            {
                drawTitles.add((String)L"K " +
                    FCTran::getValueByDigit(m_kdjK.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"K");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_kdjD.size() > 0)
            {
                drawTitles.add((String)L"D " +
                    FCTran::getValueByDigit(m_kdjD.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"D");
            }
            drawColors.add(m_indicatorColors.get(1));
            if (m_kdjJ.size() > 0)
            {
                drawTitles.add((String)L"J " +
                    FCTran::getValueByDigit(m_kdjJ.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"J");
            }
            drawColors.add(m_indicatorColors.get(2));
        }
        else if (m_showIndicator == L"RSI")
        {
            if (m_rsi1.size() > 0)
            {
                drawTitles.add((String)L"RSI6 " +
                    FCTran::getValueByDigit(m_rsi1.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"RSI6");
            }
            drawColors.add(m_indicatorColors.get(5));
            if (m_rsi2.size() > 0)
            {
                drawTitles.add((String)L"RSI12 " +
                    FCTran::getValueByDigit(m_rsi2.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"RSI12");
            }
            drawColors.add(m_indicatorColors.get(1));
            if (m_rsi3.size() > 0)
            {
                drawTitles.add((String)L"RSI24 " +
                    FCTran::getValueByDigit(m_rsi3.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"RSI24");
            }
            drawColors.add(m_indicatorColors.get(2));
        }
        else if (m_showIndicator == L"BIAS")
        {
            if (m_bias1.size() > 0)
            {
                drawTitles.add((String)L"BIAS6 " +
                    FCTran::getValueByDigit(m_bias1.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"BIAS6");
            }
            drawColors.add(m_indicatorColors.get(5));
            if (m_bias2.size() > 0)
            {
                drawTitles.add((String)L"BIAS12 " +
                    FCTran::getValueByDigit(m_bias2.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add((String)L"BIAS12");
            }
            drawColors.add(m_indicatorColors.get(1));
            if (m_bias3.size() > 0)
            {
                drawTitles.add((String)L"BIAS24 " +
                    FCTran::getValueByDigit(m_bias3.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"BIAS24");
            }
            drawColors.add(m_indicatorColors.get(2));
        }
        else if (m_showIndicator == L"ROC")
        {
            if (m_roc.size() > 0)
            {
                drawTitles.add((String)L"ROC " +
                    FCTran::getValueByDigit(m_roc.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"ROC");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_rocMa.size() > 0)
            {
                drawTitles.add((String)L"ROCMA " +
                    FCTran::getValueByDigit(m_rocMa.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"ROCMA");
            }
            drawColors.add(m_indicatorColors.get(1));
        }
        else if (m_showIndicator == L"WR")
        {
            if (m_wr1.size() > 0)
            {
                drawTitles.add((String)L"WR5 " +
                    FCTran::getValueByDigit(m_wr1.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"WR5");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_wr2.size() > 0)
            {
                drawTitles.add((String)L"WR10 " +
                    FCTran::getValueByDigit(m_wr2.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"WR10");
            }
            drawColors.add(m_indicatorColors.get(1));
        }
        else if (m_showIndicator == L"CCI")
        {
            if (m_cci.size() > 0)
            {
                drawTitles.add((String)L"CCI " +
                    FCTran::getValueByDigit(m_cci.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"CCI");
            }
            drawColors.add(m_indicatorColors.get(0));
        }
        else if (m_showIndicator == L"BBI")
        {
            if (m_bbi.size() > 0)
            {
                drawTitles.add((String)L"BBI " +
                    FCTran::getValueByDigit(m_bbi.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"BBI");
            }
            drawColors.add(m_indicatorColors.get(0));
        }
        else if (m_showIndicator == L"TRIX")
        {
            if (m_trix.size() > 0)
            {
                drawTitles.add((String)L"TRIX " +
                    FCTran::getValueByDigit(m_trix.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"TRIX");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_trixMa.size() > 0)
            {
                drawTitles.add((String)L"TRIXMA " +
                    FCTran::getValueByDigit(m_trixMa.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"TRIXMA");
            }
            drawColors.add(m_indicatorColors.get(1));
        }
        else if (m_showIndicator == L"DMA")
        {
            if (m_dma1.size() > 0)
            {
                drawTitles.add((String)L"MA10 " +
                    FCTran::getValueByDigit(m_dma1.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"MA10");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_dma2.size() > 0)
            {
                drawTitles.add((String)L"MA50 " +
                    FCTran::getValueByDigit(m_dma2.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"MA50");
            }
            drawColors.add(m_indicatorColors.get(1));
        }
        if (m_shapes.size() > 0)
        {
            for (int i = 0; i < m_shapes.size(); i++)
            {
                BaseShape *shape = m_shapes.get(i);
                if (shape->m_divIndex == 2)
                {
                    if (shape->m_title.length() > 0)
                    {
                        if (shape->m_shapeType == L"bar" && shape->m_style == L"2color")
                        {
                            drawTitles.add(shape->m_title +
                                L" " +
                                FCTran::getValueByDigit(shape->m_datas.get(crossLineIndex), m_indDigit));
                            drawColors.add(shape->m_color2);
                        }
                        else
                        {
                            if (shape->m_shapeType != L"text")
                            {
                                drawTitles.add(shape->m_title +
                                    L" " +
                                    FCTran::getValueByDigit(shape->m_datas.get(crossLineIndex)
                                        , m_indDigit));
                                drawColors.add(shape->m_color);
                                if (shape->m_datas2.size() > 0)
                                {
                                    drawTitles.add(shape->m_title2 +
                                        L" " +
                                        FCTran::getValueByDigit(shape->m_datas2.get(crossLineIndex)
                                            , m_indDigit));
                                    drawColors.add(shape->m_color2);
                                }
                            }
                        }
                    }
                }
            }
        }
        int iLeft = m_leftVScaleWidth + 5;
        for (int i = 0; i < drawTitles.size(); i++)
        {
            FCSize tSize = paint->textSize(drawTitles.get(i), getFont());
            FCRect dRect = { iLeft,
                candleDivHeight + volDivHeight + 5, iLeft + tSize.cx,
                candleDivHeight + volDivHeight + 5 + tSize.cy };
            paint->drawText(drawTitles.get(i), drawColors.get(i), getFont(), dRect);
            iLeft += tSize.cx + 5;
        }
    }
    if (indDivHeight2 > 0)
    {
        ArrayList<String> drawTitles;
        ArrayList<Long> drawColors;
        if (m_showIndicator2 == L"MACD")
        {
            if (m_alldifarr.size() > 0)
            {
                drawTitles.add((String)L"DIF " +
                    FCTran::getValueByDigit(m_alldifarr.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"DIF");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_alldeaarr.size() > 0)
            {
                drawTitles.add((String)L"DEA " +
                    FCTran::getValueByDigit(m_alldeaarr.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"DEA");
            }
            drawColors.add(m_indicatorColors.get(1));
            if (m_allmacdarr.size() > 0)
            {
                drawTitles.add((String)L"MACD " +
                    FCTran::getValueByDigit(m_allmacdarr.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"MACD");
            }
            drawColors.add(m_indicatorColors.get(4));
        }
        else if (m_showIndicator2 == L"KDJ")
        {
            if (m_kdjK.size() > 0)
            {
                drawTitles.add((String)L"K " +
                    FCTran::getValueByDigit(m_kdjK.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"K");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_kdjD.size() > 0)
            {
                drawTitles.add((String)L"D " +
                    FCTran::getValueByDigit(m_kdjD.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"D");
            }
            drawColors.add(m_indicatorColors.get(1));
            if (m_kdjJ.size() > 0)
            {
                drawTitles.add((String)L"J " +
                    FCTran::getValueByDigit(m_kdjJ.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"J");
            }
            drawColors.add(m_indicatorColors.get(2));
        }
        else if (m_showIndicator2 == L"RSI")
        {
            if (m_rsi1.size() > 0)
            {
                drawTitles.add((String)L"RSI6 " +
                    FCTran::getValueByDigit(m_rsi1.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"RSI6");
            }
            drawColors.add(m_indicatorColors.get(5));
            if (m_rsi2.size() > 0)
            {
                drawTitles.add((String)L"RSI12 " +
                    FCTran::getValueByDigit(m_rsi2.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"RSI12");
            }
            drawColors.add(m_indicatorColors.get(1));
            if (m_rsi3.size() > 0)
            {
                drawTitles.add((String)L"RSI24 " +
                    FCTran::getValueByDigit(m_rsi3.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"RSI24");
            }
            drawColors.add(m_indicatorColors.get(2));
        }
        else if (m_showIndicator2 == L"BIAS")
        {
            if (m_bias1.size() > 0)
            {
                drawTitles.add((String)L"BIAS6 " +
                    FCTran::getValueByDigit(m_bias1.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"BIAS6");
            }
            drawColors.add(m_indicatorColors.get(5));
            if (m_bias2.size() > 0)
            {
                drawTitles.add((String)L"BIAS12 " +
                    FCTran::getValueByDigit(m_bias2.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add((String)L"BIAS12");
            }
            drawColors.add(m_indicatorColors.get(1));
            if (m_bias3.size() > 0)
            {
                drawTitles.add((String)L"BIAS24 " +
                    FCTran::getValueByDigit(m_bias3.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"BIAS24");
            }
            drawColors.add(m_indicatorColors.get(2));
        }
        else if (m_showIndicator2 == L"ROC")
        {
            if (m_roc.size() > 0)
            {
                drawTitles.add((String)L"ROC " +
                    FCTran::getValueByDigit(m_roc.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"ROC");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_rocMa.size() > 0)
            {
                drawTitles.add((String)L"ROCMA " +
                    FCTran::getValueByDigit(m_rocMa.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"ROCMA");
            }
            drawColors.add(m_indicatorColors.get(1));
        }
        else if (m_showIndicator2 == L"WR")
        {
            if (m_wr1.size() > 0)
            {
                drawTitles.add((String)L"WR5 " +
                    FCTran::getValueByDigit(m_wr1.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"WR5");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_wr2.size() > 0)
            {
                drawTitles.add((String)L"WR10 " +
                    FCTran::getValueByDigit(m_wr2.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"WR10");
            }
            drawColors.add(m_indicatorColors.get(1));
        }
        else if (m_showIndicator2 == L"CCI")
        {
            if (m_cci.size() > 0)
            {
                drawTitles.add((String)L"CCI " +
                    FCTran::getValueByDigit(m_cci.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"CCI");
            }
            drawColors.add(m_indicatorColors.get(0));
        }
        else if (m_showIndicator2 == L"BBI")
        {
            if (m_bbi.size() > 0)
            {
                drawTitles.add((String)L"BBI " +
                    FCTran::getValueByDigit(m_bbi.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"BBI");
            }
            drawColors.add(m_indicatorColors.get(0));
        }
        else if (m_showIndicator2 == L"TRIX")
        {
            if (m_trix.size() > 0)
            {
                drawTitles.add((String)L"TRIX " +
                    FCTran::getValueByDigit(m_trix.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"TRIX");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_trixMa.size() > 0)
            {
                drawTitles.add((String)L"TRIXMA " +
                    FCTran::getValueByDigit(m_trixMa.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"TRIXMA");
            }
            drawColors.add(m_indicatorColors.get(1));
        }
        else if (m_showIndicator2 == L"DMA")
        {
            if (m_dma1.size() > 0)
            {
                drawTitles.add((String)L"MA10 " +
                    FCTran::getValueByDigit(m_dma1.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"MA10");
            }
            drawColors.add(m_indicatorColors.get(0));
            if (m_dma2.size() > 0)
            {
                drawTitles.add((String)L"MA50 " +
                    FCTran::getValueByDigit(m_dma2.get(crossLineIndex), m_indDigit));
            }
            else
            {
                drawTitles.add(L"MA50");
            }
            drawColors.add(m_indicatorColors.get(1));
        }
        if (m_shapes.size() > 0)
        {
            for (int i = 0; i < m_shapes.size(); i++)
            {
                BaseShape *shape = m_shapes.get(i);
                if (shape->m_divIndex == 3)
                {
                    if (shape->m_title.length() > 0)
                    {
                        if (shape->m_shapeType == L"bar" && shape->m_style == L"2color")
                        {
                            drawTitles.add(shape->m_title +
                                L" " +
                                FCTran::getValueByDigit(shape->m_datas.get(crossLineIndex), m_indDigit2));
                            drawColors.add(shape->m_color2);
                        }
                        else
                        {
                            if (shape->m_shapeType != L"text")
                            {
                                drawTitles.add(shape->m_title +
                                    L" " +
                                    FCTran::getValueByDigit(shape->m_datas.get(crossLineIndex)
                                        , m_indDigit2));
                                drawColors.add(shape->m_color);
                                if (shape->m_datas2.size() > 0)
                                {
                                    drawTitles.add(shape->m_title2 +
                                        L" " +
                                        FCTran::getValueByDigit(shape->m_datas2.get(crossLineIndex)
                                            , m_indDigit2));
                                    drawColors.add(shape->m_color2);
                                }
                            }
                        }
                    }
                }
            }
        }
        if (drawTitles.size() > 0)
        {
            int iLeft = m_leftVScaleWidth + 5;
            for (int i = 0; i < drawTitles.size(); i++)
            {
                FCSize tSize = paint->textSize(drawTitles.get(i), getFont());
                FCRect dRect = { iLeft,
                    candleDivHeight + volDivHeight + indDivHeight + 5 + tSize.cy / 2, iLeft + tSize.cx,
                    candleDivHeight + volDivHeight + indDivHeight + 5 + tSize.cy / 2 + tSize.cy };
                paint->drawText(drawTitles.get(i), drawColors.get(i), getFont(), dRect);
                iLeft += tSize.cx + 5;
            }
        }
    }

    if (this == m_native->m_touchMoveView || this == m_native->m_touchDownView)
    {
        String rightText = L"";
        if (m_touchPosition.y < candleDivHeight)
        {
            rightText = FCTran::getValueByDigit(getChartValue(m_touchPosition)
                , m_candleDigit);
        }
        else if (m_touchPosition.y > candleDivHeight &&
            m_touchPosition.y < candleDivHeight + volDivHeight)
        {
            rightText = FCTran::getValueByDigit(getChartValue(m_touchPosition) / m_magnitude
                , m_volDigit);
        }
        else if (m_touchPosition.y > candleDivHeight + volDivHeight &&
            m_touchPosition.y < candleDivHeight + volDivHeight + indDivHeight)
        {
            rightText = FCTran::getValueByDigit(getChartValue(m_touchPosition)
                , m_indDigit);
        }
        else if (m_touchPosition.y >
            candleDivHeight + volDivHeight + indDivHeight &&
            m_touchPosition.y <
            candleDivHeight + volDivHeight + indDivHeight + indDivHeight2)
        {
            rightText = FCTran::getValueByDigit(getChartValue(m_touchPosition)
                , m_indDigit2);
        }

        int drawY = m_touchPosition.y;
        if (drawY > size.cy - m_hScaleHeight)
        {
            drawY = size.cy - m_hScaleHeight;
        }
        FCSize tSize = paint->textSize(rightText, getFont());
        if (m_leftVScaleWidth > 0)
        {
            paint->fillRect(m_crossTipColor, m_leftVScaleWidth - tSize.cx, drawY - tSize.cy / 2 - 4,
                m_leftVScaleWidth, drawY + tSize.cy / 2 + 3);
            FCRect dRect = { m_leftVScaleWidth - tSize.cx, drawY - tSize.cy / 2, m_leftVScaleWidth, drawY + tSize.cy / 2 };
            paint->drawText(rightText, getTextColor(), getFont(),
                dRect);
        }
        if (m_rightVScaleWidth > 0)
        {
            paint->fillRect(m_crossTipColor, size.cx - m_rightVScaleWidth, drawY - tSize.cy / 2 - 4,
                size.cx - m_rightVScaleWidth + tSize.cx, drawY + tSize.cy / 2 + 3);
            FCRect dRect = { size.cx - m_rightVScaleWidth, drawY - tSize.cy / 2, size.cx - m_rightVScaleWidth + tSize.cx, drawY + tSize.cy / 2 };
            paint->drawText(rightText, getTextColor(), getFont(),
                dRect);
        }
        //绘制十字线
        int drawX = getChartX(m_crossStopIndex);
        if (m_targetOldX == 0 && m_targetOldX2 == 0)
        {
            drawX = m_touchPosition.x;
        }
        if (drawX < m_leftVScaleWidth)
        {
            drawX = m_leftVScaleWidth;
        }
        if (drawX > size.cx - m_rightVScaleWidth)
        {
            drawX = size.cx - m_rightVScaleWidth;
        }
        if (m_showCrossLine)
        {
            paint->drawLine(m_crossLineColor, m_lineWidthChart, 0,
                m_leftVScaleWidth, drawY, size.cx - m_rightVScaleWidth, drawY);
            paint->drawLine(m_crossLineColor, m_lineWidthChart, 0, drawX, 0,
                drawX, size.cy - m_hScaleHeight);
        }
        if (m_crossStopIndex != -1)
        {
            double dateNum = m_datas.get(m_crossStopIndex).m_date;
            String xText = FCTran::doubleToStr(dateNum);
            int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, ms = 0;
            FCTran::getDateByNum(dateNum, &year, &month, &day, &hour, &minute, &second, &ms);
            if (m_hScaleFormat.length() > 0)
            {
                xText = FCTran::getFormatDate(m_hScaleFormat, year, month, day, hour, minute, second);
            }
            else
            {
                if (m_cycle == L"day")
                {
                    xText = FCTran::getFormatDate(L"yyyy-MM-dd", year, month, day, hour, minute, second);
                }
                else if (m_cycle == L"minute")
                {
                    xText = FCTran::getFormatDate(L"HH:mm", year, month, day, hour, minute, second);
                }
                else if (m_cycle == L"trend")
                {
                    xText = FCTran::getFormatDate(L"HH:mm", year, month, day, hour, minute, second);
                }
                else if (m_cycle == L"second")
                {
                    xText = FCTran::getFormatDate(L"HH:mm:ss", year, month, day, hour, minute, second);
                }
                else if (m_cycle == L"tick")
                {
                    xText = FCTran::intToStr(m_crossStopIndex + 1);
                }
            }
            FCSize xSize = paint->textSize(xText, getFont());
            paint->fillRect(
                m_crossTipColor,
                drawX - xSize.cx / 2 - 2,
                candleDivHeight + volDivHeight + indDivHeight,
                drawX + xSize.cx / 2 + 2,
                candleDivHeight + volDivHeight + indDivHeight + xSize.cy + 6);
            FCRect dRect = { drawX - xSize.cx / 2,
                candleDivHeight + volDivHeight + indDivHeight + 3, drawX + xSize.cx / 2,
                candleDivHeight + volDivHeight + indDivHeight + 3 + xSize.cy };
            paint->drawText(xText, getTextColor(), getFont(), dRect);
        }
    }
}

void FCChartEx::drawChartScale(FCPaint* paint, const FCRect& clipRect) {
    FCSize size = getSize();
    if (m_leftVScaleWidth > 0)
    {
        paint->drawLine(m_scaleColor, m_lineWidthChart, 0,
            m_leftVScaleWidth, 0, m_leftVScaleWidth,
            size.cy - m_hScaleHeight);
    }
    if (m_rightVScaleWidth > 0)
    {
        paint->drawLine(m_scaleColor, m_lineWidthChart, 0,
            size.cx - m_rightVScaleWidth, 0, size.cx - m_rightVScaleWidth,
            size.cy - m_hScaleHeight);
    }
    if (m_hScaleHeight > 0)
    {
        paint->drawLine(m_scaleColor, m_lineWidthChart, 0, 0,
            size.cy - m_hScaleHeight, size.cx, size.cy - m_hScaleHeight);
    }
    int candleDivHeight = getCandleDivHeight();
    int volDivHeight = getVolDivHeight();
    int indDivHeight = getIndDivHeight();
    int indDivHeight2 = getIndDivHeight2();
    if (volDivHeight > 0)
    {
        paint->drawLine(m_scaleColor, m_lineWidthChart, 0,
            m_leftVScaleWidth, candleDivHeight, size.cx - m_rightVScaleWidth, candleDivHeight);
    }
    if (indDivHeight > 0)
    {
        paint->drawLine(m_scaleColor, m_lineWidthChart, 0,
            m_leftVScaleWidth, candleDivHeight + volDivHeight,
            size.cx - m_rightVScaleWidth,
            candleDivHeight + volDivHeight);
    }
    if (indDivHeight2 > 0)
    {
        paint->drawLine(m_scaleColor, m_lineWidthChart, 0,
            m_leftVScaleWidth, candleDivHeight + volDivHeight + indDivHeight,
            size.cx - m_rightVScaleWidth,
            candleDivHeight + volDivHeight + indDivHeight);
    }
    if (m_datas.size() > 0)
    {
        FCPoint topPoint = { 0, 20 };
        FCPoint bottomPoint = { 0, candleDivHeight - 10 };
        double candleMax = getChartValue(topPoint);
        double candleMin = getChartValue(bottomPoint);
        chartGridScale(candleMin, candleMax, (candleDivHeight - m_candlePaddingTop - m_candlePaddingBottom) / 2,
            m_vScaleDistance, m_vScaleDistance / 2,
            (candleDivHeight - m_candlePaddingTop - m_candlePaddingBottom) / m_vScaleDistance);
        if (m_gridStep > 0)
        {
            ArrayList<double> drawValues;
            bool isTrend = m_cycle == L"trend";
            double firstOpen = m_firstOpen;
            if (isTrend)
            {
                if(firstOpen == 0){
                    firstOpen = m_datas.get(m_firstVisibleIndex).m_close;
                }
                double subValue = (candleMax - candleMin);
                int count = (candleDivHeight -
                    m_candlePaddingTop -
                    m_candlePaddingBottom) /
                    m_vScaleDistance;
                if (count > 0)
                {
                    subValue /= count;
                }
                double start = firstOpen;
                while (start < candleMax)
                {
                    start += subValue;
                    if (start <= candleMax)
                    {
                        drawValues.add(start);
                    }
                }
                start = firstOpen;
                while (start > candleMin)
                {
                    start -= subValue;
                    if (start >= candleMin)
                    {
                        drawValues.add(start);
                    }
                }
            }
            else
            {
                double start = 0;
                if (candleMin >= 0)
                {
                    while (start + m_gridStep < candleMin)
                    {
                        start += m_gridStep;
                    }
                }
                else
                {
                    while (start - m_gridStep > candleMin)
                    {
                        start -= m_gridStep;
                    }
                }

                while (start <= candleMax)
                {
                    if (start > candleMin)
                    {
                        drawValues.add(start);
                    }
                    start += m_gridStep;
                }
            }
            drawValues.add(firstOpen);
            for (int i = 0; i < drawValues.size(); i++)
            {
                double start = drawValues.get(i);
                int hAxisY = getChartY(0, start);
                if (hAxisY < 1 || hAxisY > candleDivHeight)
                {
                    continue;
                }
                paint->drawLine(m_gridColor, m_lineWidthChart, 0,
                    m_leftVScaleWidth, hAxisY,
                    size.cx - m_rightVScaleWidth, hAxisY);
                paint->drawLine(m_scaleColor, m_lineWidthChart, 0,
                    m_leftVScaleWidth - 8, hAxisY, m_leftVScaleWidth, hAxisY);
                paint->drawLine(m_scaleColor, m_lineWidthChart, 0,
                    size.cx - m_rightVScaleWidth, hAxisY,
                    size.cx - m_rightVScaleWidth + 8, hAxisY);

                String drawText = FCTran::getValueByDigit(start, m_candleDigit);

                FCSize tSize = paint->textSize(drawText, getFont());
                if (isTrend)
                {
                    double diffRange = ((start - firstOpen) / firstOpen * 100);
                    String diffRangeStr = FCTran::getValueByDigit(diffRange, 2) + L"%";
                    FCSize dSize = paint->textSize(diffRangeStr, getFont());
                    if (diffRange >= 0)
                    {
                        FCRect dRect = { size.cx - m_rightVScaleWidth + 10,
                                hAxisY - tSize.cy / 2, size.cx - m_rightVScaleWidth + 10 + dSize.cx,
                                hAxisY + tSize.cy / 2 };
                        paint->drawText(diffRangeStr, m_upColor, getFont(),
                            dRect);
                    }
                    else
                    {
                        FCRect dRect = { size.cx - m_rightVScaleWidth + 10,
                                hAxisY - tSize.cy / 2, size.cx - m_rightVScaleWidth + 10 + dSize.cx,
                                hAxisY + tSize.cy / 2 };
                        paint->drawText(diffRangeStr, m_downColor, getFont(),
                            dRect);
                    }
                }
                else
                {
                    FCRect dRect = { size.cx - m_rightVScaleWidth + 10,
                        hAxisY - tSize.cy / 2, size.cx - m_rightVScaleWidth + 10 + tSize.cx,
                        hAxisY + tSize.cy / 2 };
                    paint->drawText(drawText, getTextColor(), getFont(), dRect);
                }
                FCRect ddRect = { m_leftVScaleWidth - tSize.cx - 10, hAxisY - tSize.cy / 2, m_leftVScaleWidth - 10, hAxisY + tSize.cy / 2 };
                paint->drawText(drawText, getTextColor(), getFont(),
                    ddRect);
            }
        }
        topPoint.x = 0;
        topPoint.y = candleDivHeight + 10 ;
        bottomPoint.x = 0;
        bottomPoint.y = candleDivHeight + volDivHeight - 10;
        double volMax = getChartValue(topPoint);
        double volMin = getChartValue(bottomPoint);
        chartGridScale(volMin, volMax, (volDivHeight - m_volPaddingTop - m_volPaddingBottom) / 2,
            m_vScaleDistance, m_vScaleDistance / 2,
            (volDivHeight - m_volPaddingTop - m_volPaddingBottom) / m_vScaleDistance);
        if (m_gridStep > 0)
        {
            double start = 0;
            if (volMin >= 0)
            {
                while (start + m_gridStep < volMin)
                {
                    start += m_gridStep;
                }
            }
            else
            {
                while (start - m_gridStep > volMin)
                {
                    start -= m_gridStep;
                }
            }
            while (start <= volMax)
            {
                if (start > volMin)
                {
                    int hAxisY = getChartY(1, start);
                    if (hAxisY < candleDivHeight ||
                        hAxisY > candleDivHeight + volDivHeight)
                    {
                        start += m_gridStep;
                        continue;
                    }
                    paint->drawLine(m_gridColor, m_lineWidthChart, 0, m_leftVScaleWidth,
                        hAxisY, size.cx - m_rightVScaleWidth, hAxisY);
                    paint->drawLine(m_scaleColor, m_lineWidthChart, 0,
                        m_leftVScaleWidth - 8, hAxisY, m_leftVScaleWidth, hAxisY);
                    paint->drawLine(m_scaleColor, m_lineWidthChart, 0, size.cx - m_rightVScaleWidth,
                        hAxisY, size.cx - m_rightVScaleWidth + 8, hAxisY);
                    String drawText =
                        FCTran::getValueByDigit(start / m_magnitude, m_volDigit);
                    FCSize tSize = paint->textSize(drawText, getFont());
                    FCRect dRect = { size.cx - m_rightVScaleWidth + 10,
                            hAxisY - tSize.cy / 2, size.cx - m_rightVScaleWidth + 10 + tSize.cx,
                            hAxisY + tSize.cy / 2 };
                    paint->drawText(drawText, getTextColor(), getFont(),
                        dRect);
                    FCRect dRect2 = { m_leftVScaleWidth - tSize.cx - 10, hAxisY - tSize.cy / 2, m_leftVScaleWidth - 10, hAxisY + tSize.cy / 2 };
                    paint->drawText(drawText, getTextColor(), getFont(),
                        dRect2);
                }
                start += m_gridStep;
            }
        }
        if (indDivHeight > 0)
        {
            topPoint.x = 0;
            topPoint.y = candleDivHeight + volDivHeight + 10;
            bottomPoint.x = 0;
            bottomPoint.y = candleDivHeight + volDivHeight + indDivHeight - 10;
            double indMax = getChartValue(topPoint);
            double indMin = getChartValue(bottomPoint);
            chartGridScale(indMin, indMax, (indDivHeight - m_indPaddingTop - m_indPaddingBottom) / 2,
                m_vScaleDistance, m_vScaleDistance / 2,
                (indDivHeight - m_indPaddingTop - m_indPaddingBottom) / m_vScaleDistance);
            if (m_gridStep > 0)
            {
                double start = 0;
                if (indMin >= 0)
                {
                    while (start + m_gridStep < indMin)
                    {
                        start += m_gridStep;
                    }
                }
                else
                {
                    while (start - m_gridStep > indMin)
                    {
                        start -= m_gridStep;
                    }
                }

                while (start <= indMax)
                {
                    if (start > indMin)
                    {
                        int hAxisY = getChartY(2, start);
                        if (hAxisY < candleDivHeight + volDivHeight ||
                            hAxisY > candleDivHeight + volDivHeight + indDivHeight)
                        {
                            start += m_gridStep;
                            continue;
                        }
                        paint->drawLine(m_gridColor, m_lineWidthChart, 0, m_leftVScaleWidth, hAxisY, size.cx - m_rightVScaleWidth, hAxisY);
                        paint->drawLine(m_scaleColor, m_lineWidthChart, 0, m_leftVScaleWidth - 8, hAxisY, m_leftVScaleWidth, hAxisY);
                        paint->drawLine(m_scaleColor, m_lineWidthChart, 0,
                            size.cx - m_rightVScaleWidth, hAxisY, size.cx - m_rightVScaleWidth + 8, hAxisY);
                        String drawText = FCTran::getValueByDigit(start, m_indDigit);
                        FCSize tSize = paint->textSize(drawText, getFont());
                        FCRect dRect = { size.cx - m_rightVScaleWidth + 10,
                                hAxisY - tSize.cy / 2, size.cx - m_rightVScaleWidth + 10 + tSize.cx,
                                hAxisY + tSize.cy / 2 };
                        paint->drawText(drawText, getTextColor(), getFont(),
                            dRect);
                        FCRect dRect2 = { m_leftVScaleWidth - tSize.cx - 10, hAxisY - tSize.cy / 2, m_leftVScaleWidth - 10, hAxisY + tSize.cy / 2 };
                        paint->drawText(drawText, getTextColor(), getFont(),
                            dRect2);
                    }
                    start += m_gridStep;
                }
            }
        }
        if (indDivHeight2 > 0)
        {
            topPoint.x = 0;
            topPoint.y = candleDivHeight + volDivHeight + indDivHeight + 10;
            bottomPoint.x = 0;
            bottomPoint.y = candleDivHeight + volDivHeight + indDivHeight + indDivHeight2 - 10;
            double indMax2 = getChartValue(topPoint);
            double indMin2 = getChartValue(bottomPoint);
            chartGridScale(indMin2, indMax2, (indDivHeight2 - m_indPaddingTop2 - m_indPaddingBottom2) / 2, m_vScaleDistance, m_vScaleDistance / 2, (indDivHeight2 - m_indPaddingTop2 - m_indPaddingBottom2) /
                m_vScaleDistance);
            if (m_gridStep > 0)
            {
                double start = 0;
                if (indMin2 >= 0)
                {
                    while (start + m_gridStep < indMin2)
                    {
                        start += m_gridStep;
                    }
                }
                else
                {
                    while (start - m_gridStep > indMin2)
                    {
                        start -= m_gridStep;
                    }
                }

                while (start <= indMax2)
                {
                    if (start > indMin2)
                    {
                        int hAxisY = getChartY(3, start);
                        if (hAxisY < candleDivHeight + volDivHeight + indDivHeight || hAxisY > candleDivHeight + volDivHeight + indDivHeight + indDivHeight2)
                        {
                            start += m_gridStep;
                            continue;
                        }
                        paint->drawLine(m_gridColor, m_lineWidthChart, 0, m_leftVScaleWidth, hAxisY, size.cx - m_rightVScaleWidth, hAxisY);
                        paint->drawLine(m_scaleColor, m_lineWidthChart, 0, m_leftVScaleWidth - 8, hAxisY, m_leftVScaleWidth, hAxisY);
                        paint->drawLine(m_scaleColor, m_lineWidthChart, 0, size.cx - m_rightVScaleWidth, hAxisY, size.cx - m_rightVScaleWidth + 8, hAxisY);
                        String drawText = FCTran::getValueByDigit(start, m_indDigit);
                        FCSize tSize = paint->textSize(drawText, getFont());
                        FCRect dRect = { size.cx - m_rightVScaleWidth + 10, hAxisY - tSize.cy / 2, size.cx - m_rightVScaleWidth + 10 + tSize.cx, hAxisY + tSize.cy / 2 };
                        paint->drawText(drawText, getTextColor(), getFont(), dRect);
                        FCRect dRect2 = { m_leftVScaleWidth - tSize.cx - 10, hAxisY - tSize.cy / 2, m_leftVScaleWidth - 10, hAxisY + tSize.cy / 2 };
                        paint->drawText(drawText, getTextColor(), getFont(),
                            dRect2);
                    }
                    start += m_gridStep;
                }
            }
        }
    }
    if (m_datas.size() > 0 && m_hScaleHeight > 0)
    {
        Long newScaleColor = getTextColor();
        if (MyColor::getStyle() == 0)
        {
            newScaleColor = FCColor::rgb(233, 153, 46);
        }
        if (m_cycle == L"trend")
        {
            ArrayList<double> times;
            if (getWidth() < 600)
            {
                times.add(FCTran::getDateNum(1970, 1, 1, 10, 30, 0, 0));
                times.add(FCTran::getDateNum(1970, 1, 1, 11, 30, 0, 0));
                times.add(FCTran::getDateNum(1970, 1, 1, 14, 0, 0, 0));
            }
            else
            {
                times.add(FCTran::getDateNum(1970, 1, 1, 10, 0, 0, 0));
                times.add(FCTran::getDateNum(1970, 1, 1, 10, 30, 0, 0));
                times.add(FCTran::getDateNum(1970, 1, 1, 11, 0, 0, 0));
                times.add(FCTran::getDateNum(1970, 1, 1, 11, 30, 0, 0));
                times.add(FCTran::getDateNum(1970, 1, 1, 13, 30, 0, 0));
                times.add(FCTran::getDateNum(1970, 1, 1, 14, 0, 0, 0));
                times.add(FCTran::getDateNum(1970, 1, 1, 14, 30, 0, 0));
            }
            int bBottom = getHeight();
            String leftStr = L"9:30";
            FCSize leftSize = paint->textSize(leftStr, getFont(), -1);
            String rightStr = L"15:00";
            FCSize rightSize = paint->textSize(rightStr, getFont(), -1);
            paint->drawText(leftStr, newScaleColor, getFont(), FCRect({m_leftVScaleWidth + 5, bBottom - (m_hScaleHeight + leftSize.cy) / 2, m_leftVScaleWidth + leftSize.cx + 5, bBottom - (m_hScaleHeight - leftSize.cy) / 2}), -1);
            paint->drawText(rightStr, newScaleColor, getFont(), FCRect({size.cx - m_rightVScaleWidth - rightSize.cx - 5, bBottom - (m_hScaleHeight + leftSize.cy) / 2, size.cx - m_rightVScaleWidth - 5, bBottom - (m_hScaleHeight - leftSize.cy) / 2}), -1);
            for (int i = m_firstVisibleIndex; i <= m_lastVisibleIndex; i++)
            {
                double dateNum = m_datas.get(i).m_date;
                int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, ms = 0;
                FCTran::getDateByNum(dateNum, &year, &month, &day, &hour, &minute, &second, &ms);
                double timeNum = FCTran::getDateNum(1970, 1, 1, hour, minute, 0, 0);
                bool contains = false;
                for (int i = 0; i < times.size(); i++)
                {
                    if(times.get(i) == timeNum)
                    {
                        contains = true;
                        break;
                    }
                }
                if (contains)
                {
                   String xText = FCTran::getFormatDate(L"HH:mm", year, month, day, hour, minute, second);
                    FCSize tSize = paint->textSize(xText, getFont(), -1);
                    int x = getChartX(i);
                    int dx = x - tSize.cx / 2;
                    paint->drawLine(m_scaleColor, m_lineWidthChart, 0, x, bBottom - m_hScaleHeight, x, bBottom - m_hScaleHeight + 5);
                    paint->drawText(xText, newScaleColor, getFont(), FCRect({dx, bBottom - (m_hScaleHeight + leftSize.cy) / 2, dx + tSize.cx, bBottom - (m_hScaleHeight - leftSize.cy) / 2}), -1);
                    paint->drawLine(m_gridColor, 1, 0, x, 0, x, bBottom - m_hScaleHeight);
                }
            }
        }
        else
        {
            double dLeft = m_leftVScaleWidth;
            if (m_cycle == L"day")
            {
                int fIndex = m_firstVisibleIndex;
                int lIndex = m_lastVisibleIndex;
                if (lIndex >= fIndex)
                {
                    ArrayList<double> dates;
                    for (int d = fIndex; d <= lIndex; d++)
                    {
                        dates.add(m_datas.get(d).m_date);
                    }
                    int drawLeft = m_leftVScaleWidth;
                    int i = fIndex;
                    int lastYear = 0;
                    ArrayList<int> drawYearsCache;
                    int lastTextRight = 0;
                    ArrayList<int> timeCache;
                    ArrayList<int> yearTextLeftCache;
                    ArrayList<int> yearTextRightCache;
                    int textPadding = 5;
                    int bBottom = getHeight();
                    while (i <= lIndex)
                    {
                        int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, ms = 0;
                        FCTran::getDateByNum(dates.get(i - fIndex), &year, &month, &day, &hour, &minute, &second, &ms);
                        timeCache.add(year * 100 + month);
                        int x = getChartX(i);
                        if (year != lastYear && x >= drawLeft && x < size.cx - m_rightVScaleWidth)
                        {
                            String xText = FCTran::intToStr(year);
                            FCSize tSize = paint->textSize(xText, getFont(), -1);
                            int tLeft = x + 2;
                            if (tLeft > lastTextRight)
                            {
                                paint->drawLine(m_scaleColor, 1, 0, x, bBottom - m_hScaleHeight, x, bBottom);
                                FCDraw::drawText(paint, xText, newScaleColor, getFont(), tLeft, bBottom - (m_hScaleHeight + tSize.cy) / 2);
                                yearTextLeftCache.add(tLeft);
                                yearTextRightCache.add(tLeft + tSize.cx + 5);
                                drawYearsCache.add(year);
                                lastTextRight = tLeft + tSize.cx + 5;
                                lastYear = year;
                            }
                        }
                        i = i + 1;
                    }
                    MyChart *my_Chart = (MyChart*)m_myChart;
                    if (my_Chart->m_cycle <= 1440)
                    {
                        for (int m = 0; m < drawYearsCache.size(); m++)
                        {
                            int cacheYear = drawYearsCache.get(m);
                            int lastMonth = 0;
                            i = m_firstVisibleIndex;
                            lastTextRight = 0;
                            while (i <= lIndex)
                            {
                                int year = timeCache.get(i - m_firstVisibleIndex) / 100;
                                if (cacheYear == year)
                                {
                                    int month = timeCache.get(i - m_firstVisibleIndex) % 100;
                                    int x = getChartX(i);
                                    if (lastMonth != month && x >= drawLeft && x < size.cx - m_rightVScaleWidth)
                                    {
                                        String xText = FCTran::intToStr(month);
                                        if (xText.length() == 1)
                                        {
                                            xText = String(L"0") + xText;
                                        }
                                        FCSize tSize = paint->textSize(xText, getFont(), -1);
                                        if (x > lastTextRight + textPadding)
                                        {
                                            if ((x > yearTextRightCache.get(m) + textPadding)
                                            && ((m == drawYearsCache.size() - 1)
                                            || ((m < drawYearsCache.size() - 1)
                                            && (x + tSize.cx < yearTextLeftCache.get(m+1) - textPadding))))
                                            {
                                                paint->drawLine(m_scaleColor, 1, 0, x, bBottom - m_hScaleHeight, x, bBottom - m_hScaleHeight + 12); //���ƿ̶�
                                                FCDraw::drawText(paint, xText, newScaleColor, getFont(), x + 2, bBottom - (m_hScaleHeight + tSize.cy) / 2);
                                                lastTextRight = x + tSize.cx + 2;
                                            }
                                        }
                                        lastMonth = month;
                                    }
                                }
                                else if (cacheYear < year)
                                {
                                    break;
                                }
                                i = i + 1;
                            }
                        }
                    }
                }
            }
            else
            {
                int fIndex = m_firstVisibleIndex;
                int lIndex = m_lastVisibleIndex;
                if (lIndex >= fIndex)
                {
                    double lastDate2 = 0;
                    ArrayList<double> dates;
                    for (int d = fIndex; d <= lIndex; d++)
                    {
                        dates.add(m_datas.get(d).m_date);
                    }
                    int lastYear = 0;
                    for (int i = fIndex; i <= lIndex; i++)
                    {
                        double dateNum = dates.get(i - fIndex);
                        String xText = FCTran::intToStr(dateNum);
                        int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, ms = 0;
                        FCTran::getDateByNum(dateNum, &year, &month, &day, &hour, &minute, &second, &ms);
                        if (year != lastYear)
                        {
                            xText = FCTran::getFormatDate(L"yyyy/MM/dd", year, month, day, hour, minute, second);
                        }
                        else
                        {
                            xText = FCTran::getFormatDate(L"MM/dd", year, month, day, hour, minute, second);
                        }
                        if ((int)(lastDate2 / 86400) != (int)(dateNum / 86400))
                        {
                            lastDate2 = dateNum;
                            lastYear = year;
                            FCSize tSize = paint->textSize(xText, getFont(), -1);
                            int x = getChartX(i);
                            int dx = x + 2;
                            if (dx > dLeft && dx + tSize.cx < size.cx - m_rightVScaleWidth - 5)
                            {
                                int bBottom = getHeight();
                                paint->drawLine(m_scaleColor, m_lineWidthChart, 0, x, bBottom - m_hScaleHeight, x, bBottom - m_hScaleHeight + 12);
                                paint->drawText(xText, newScaleColor, getFont(), FCRect({dx, bBottom - m_hScaleHeight / 2 - tSize.cy / 2, dx + tSize.cx, bBottom - m_hScaleHeight / 2 + tSize.cy / 2}), -1);
                                i = i + (int)((tSize.cx + m_hScaleTextDistance) / m_hScalePixel) + 1;
                            }
                        }
                    }
                }
            }
        }
    }
}
